package com.nuanshui.framework.schedule.conf;

import java.util.Map;

/**
 * 配置信息
 * Created by hh on 9/8/15.
 */
public class ZkConfig {

    /**
     * zookeeper的连接字符串
     */
    private String cxnString;
    /**
     * 跟节点
     */
    private String rootPath;
    /**
     * 是否自动注册
     */
    private boolean autoRegisterTask = true;
    /**
     * 服务节点名称
     */
    private String serverNode = "server";
    /**
     * 任务节点名称
     */
    private String taskNode = "task";
    /**
     * 停掉任务的节点名称
     */
    private String ignoreTaskServerNode = "ignore_server";
    /**
     * 服务节点心跳超时时间(多久没有心跳就超时)
     */
    private long serverExpireTime = 10 * 1000L;
    /**
     * 是否所有节点都运行(同一个任务是否可以同时在多个节点同时执行)
     */
    private boolean runInAll = false;
    /**
     * 是否启用任务调度, 在系统启动时有效(总开关)
     */
    private boolean start = true;
    /**
     * 是否停止调度，会停当前节点的所有任务。只能停止再次调度，不能停止已经执行的任务
     */
    private boolean stopSchedule = false;
    /**
     * 需要停止运行的任务<任务名,是否所有节点>
     */
    private Map<String, Boolean> ignoreTaskMap;

    public String getCxnString() {
        return cxnString;
    }

    public void setCxnString(String cxnString) {
        this.cxnString = cxnString;
    }

    public String getRootPath() {
        return rootPath;
    }

    public void setRootPath(String rootPath) {
        this.rootPath = rootPath;
    }

    public boolean isAutoRegisterTask() {
        return autoRegisterTask;
    }

    public void setAutoRegisterTask(boolean autoRegisterTask) {
        this.autoRegisterTask = autoRegisterTask;
    }

    public String getServerNode() {
        return serverNode;
    }

    public void setServerNode(String serverNode) {
        this.serverNode = serverNode;
    }

    public String getTaskNode() {
        return taskNode;
    }

    public void setTaskNode(String taskNode) {
        this.taskNode = taskNode;
    }

    public long getServerExpireTime() {
        return serverExpireTime;
    }

    public void setServerExpireTime(long serverExpireTime) {
        this.serverExpireTime = serverExpireTime;
    }

    public boolean isRunInAll() {
        return runInAll;
    }

    public void setRunInAll(boolean runInAll) {
        this.runInAll = runInAll;
    }

    public boolean isStart() {
        return start;
    }

    public void setStart(boolean start) {
        this.start = start;
    }

    public boolean isStopSchedule() {
        return stopSchedule;
    }

    public void setStopSchedule(boolean stopSchedule) {
        this.stopSchedule = stopSchedule;
    }

    public String getIgnoreTaskServerNode() {
        return ignoreTaskServerNode;
    }

    public void setIgnoreTaskServerNode(String ignoreTaskServerNode) {
        this.ignoreTaskServerNode = ignoreTaskServerNode;
    }

    public Map<String, Boolean> getIgnoreTaskMap() {
        return ignoreTaskMap;
    }

    public void setIgnoreTaskMap(Map<String, Boolean> ignoreTaskMap) {
        this.ignoreTaskMap = ignoreTaskMap;
    }

    @Override
    public String toString() {
        return "ZkConfig{" +
                "cxnString='" + cxnString + '\'' +
                ", rootPath='" + rootPath + '\'' +
                ", autoRegisterTask=" + autoRegisterTask +
                ", serverNode='" + serverNode + '\'' +
                ", taskNode='" + taskNode + '\'' +
                ", ignoreTaskServerNode='" + ignoreTaskServerNode + '\'' +
                ", serverExpireTime=" + serverExpireTime +
                ", runInAll=" + runInAll +
                ", start=" + start +
                ", stopSchedule=" + stopSchedule +
                ", ignoreTaskMap=" + ignoreTaskMap +
                '}';
    }

    static class Constant {
        /************************配置项 KEY*******************/
        public static final String CXN_STRING = "connectionString";
        public static final String PRE_PATH = "prePath";
        public static final String AUTO_REGISTER_TASK = "autoRegisterTask";
        public static final String RUN_IN_ALL = "runInAll";
        public static final String START = "start";
        public static final String IGNORE_TASK = "ignoreTask";

        /************************配置文件*******************/
        public static final String CONF_PATH = "zk-schedule.properties";

    }

}
